from appium.webdriver.common.appiumby import AppiumBy as By
from pages.base_page import BasePage

# 定位器
my_locator = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().text("我")')
creation_locator = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().text("作品 0")')
creation_locator_01 = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().text("作品 1")')
share_creation_locator = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().resourceId("com.xiachufang:id/profile_empty_recipe_header_create_recipe_btn")')
photo_locator = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().resourceId("com.xiachufang:id/item_photo_picker_photo").instance(1)')
tv_next_step_locator = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().resourceId("com.xiachufang:id/tv_next_step")')
dish_desc_locator = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().resourceId("com.xiachufang:id/dish_desc")')
afternoon_te_locator = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().text("下午茶")')
create_dish_weibo_toggle_locator = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().resourceId("com.xiachufang:id/create_dish_weibo_toggle")')
close_locator = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().text("关闭")')
dish_update_image_locator = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().resourceId("com.xiachufang:id/dish_update_image")')

ib_share_locator = (By.ID, 'com.xiachufang:id/ib_share')
item_share_icon_locator_05 = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().resourceId("com.xiachufang:id/item_share_icon").instance(5)')
navigation_right_btn_locator = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().resourceId("com.xiachufang:id/navigation_right_btn")')
iv_dish_locator = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().resourceId("com.xiachufang:id/iv_dish")')
common_control_panel_more_btn_locator = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().resourceId("com.xiachufang:id/common_control_panel_more_btn")')
delete_locator = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().text("删除")')
button1_locator = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().resourceId("android:id/button1")')




class MyCreationPage(BasePage):

    def click_my(self):
        """
        点击我
        :return:
        """
        self.find_element(my_locator).click()

    def click_creation(self):
        """
        点击作品
        :return:
        """
        self.find_element(creation_locator).click()


    def click_share_creation(self):
        """
        点击发布作品
        :return:
        """
        self.find_element(share_creation_locator).click()

    def click_photo(self):
        """
        点击图片
        :return:
        """
        self.find_element(photo_locator).click()
    def click_tv_next_step(self):
        """
        点击下一步
        :return:
        """
        self.find_element(tv_next_step_locator).click()
    def input_dish_desc(self):
        """
        输入作品描述
        :param text:
        :return:
        """
        self.find_element(dish_desc_locator).send_keys("美汁汁儿")

    def click_afternoon_te(self):
        """
        点击下午茶
        :return:
        """
        self.find_element(afternoon_te_locator).click()

    def click_create_dish_weibo_toggle(self):
        """
        点击发布到微头条
        :return:
        """
        self.find_element(create_dish_weibo_toggle_locator).click()

    def click_close(self):
        """
        点击关闭
        :return:
        """
        self.find_element(close_locator).click()

    def click_dish_update_image(self):
        """
        点击发布
        :return:
        """
        self.find_element(dish_update_image_locator).click()

    def click_ib_share(self):
        """
        点击分享
        :return:
        """
        self.find_element(ib_share_locator).click()

    def click_item_share_icon_05(self):
        """
        点击复制链接
        :return:
        """
        self.find_element(item_share_icon_locator_05).click()

    def click_navigation_right_btn(self):
        """
        点击关闭
        :return:
        """
        self.find_element(navigation_right_btn_locator).click()

    def click_item_img(self):
        """
        点击作品
        :return:
        """
        self.find_element(iv_dish_locator).click()

    def click_description(self):
        """
        点击编辑
        :return:
        """
        self.find_element(common_control_panel_more_btn_locator).click()

    def click_delete(self):
        """
        点击删除
        :return:
        """
        self.find_element(delete_locator).click()

    def click_button(self):
        """
        点击确认删除
        :return:
        """
        self.find_element(button1_locator).click()